package net.m510.autosurfer.idemitsu;

import java.net.URI;
import java.util.List;
import java.util.logging.Logger;

import net.m510.autosurfer.common.DocumentPostProcess;
import net.m510.autosurfer.core.Parameters;

import org.apache.http.HttpHost;
import org.apache.http.NameValuePair;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.impl.client.CloseableHttpClient;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.FormElement;

public class IdemitsuGoBillDetail extends DocumentPostProcess {
	public IdemitsuGoBillDetail() {
		this(null,null);
	}

	public IdemitsuGoBillDetail(CloseableHttpClient client, HttpClientContext context) {
		super(client, context);
		super.log = Logger.getLogger(IdemitsuGoBillDetail.class.getName());
	}

	@Override
	protected List<NameValuePair> getRequestParameters(Document doc) {
		FormElement form = doc.getAllElements().forms().get(0);
		Parameters p = Parameters.create(form);
		p.remove("name=forward_USC0102BLC01_targetMonthDiv=2");
		p.remove("name=forward_USC0102BLC01_targetMonthDiv=3");
		return p.asNameValueList();
	}
	
	@Override
	protected URI getUri(Document doc) {
		String action = doc.getAllElements().forms().get(0).attr("action");
		HttpHost host = context.getTargetHost();
		URI uri = URI.create(host.toURI());
		uri = uri.resolve(action);
		return uri;
	}

}
